package com.crm.cust.controller;

import com.crm.cust.entity.Cust;
import com.crm.cust.service.CustService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("api/custcenter/custs")
public class CustController {
    @Autowired
    private CustService custService;

    @PostMapping
    public Long add(@RequestBody Cust cust){
        return custService.add(cust);
    }
    @DeleteMapping("{custId}")
    public int del(@PathVariable("custId") Long custId){
        return custService.delete(custId);
    }
    @PutMapping("{custId}")
    public int update(@PathVariable("custId") Long custId,@RequestBody Cust cust){
        cust.setCustId(custId);
        return custService.update(cust);
    }
    @GetMapping("{custId}")
    public Cust get(@PathVariable("custId")Long custId){
        return custService.get(custId);
    }
    @GetMapping
    public List<Cust> query(String custType, String custName, String custNumber){
        return custService.query(custType,custName,custNumber);
    }
}
